<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
	xmlns:p="http://primefaces.org/ui" xml:lang="pt" lang="pt-br">

<f:view contentType="text/html">
	<h:head>

		<f:facet name="first">
			<meta http-equiv="X-UA-Compatible" content="EmulateIE8" />
			<meta content='text/html; charset=UTF-8' http-equiv="Content-Type" />
			<title>Sos:Professor</title>
		</f:facet>

		<h:outputStylesheet name="css/default.css" />
		<h:outputStylesheet name="css/estilo.css" />
		<h:outputScript name="locale-primefaces.js" library="js" />
	</h:head>
	<h:body id="bodyy">
		<p:layout fullPage="true">
			<p:layoutUnit id="bottom" position="south" size="60">
				<ui:include src="../rodape.xhtml" />
			</p:layoutUnit>
			<p:layoutUnit id="center" position="center">
				<h:form id="formMenu">
					<p:menubar autoSubmenuDisplay="true">
						<p:menuitem value="Minhas Reservas" url="#" style="font-size: 17px;"/>
						<p:menuitem value="Reservas pendente" url="#" style="font-size: 17px;"/>
						<p:menuitem value="Sair" actionListener="#{loginManager.logOut}" 
							helpText="CTRL+p" style="float:right; font-size: 17px;" />
					</p:menubar>
				</h:form>
				<div id="corpo">
					<h:form id="formSolicitacao">
						<p:panel header="Solicitação de Reserva de Sala" style="box-shadow: 1px 5px 15px 1px #888;">
							<h:panelGrid columns="2">
								<h:outputText value="Capacidade: " />
								<p:inputText id="nrAluno" 
									value="#{professorManager.solicitacao.nrAlunos}" size="5"
									maxlength="3" required="true" label="Capacidade"
									validatorMessage="campo invalido, este campo deve conter números">
									<f:validateLongRange minimum="1"/>
								</p:inputText>

								<h:outputText value="Data: " />
								<p:calendar value="#{professorManager.data}" mindate="#{salaManager.currentDate()}"
									pattern="dd/MM/yyyy" required="true" label="Data" locale="pt" />

								<h:outputText value="Horário Inicial: " />
								<p:calendar id="inicio" value="#{professorManager.solicitacao.dataInicial}"
									pattern="HH:mm" timeOnly="true" required="true" label="Horário Inicial" locale="pt" />

								<h:outputText value="Horário Final: " />
								<p:calendar id="fim" value="#{professorManager.solicitacao.dataFinal}"
									pattern="HH:mm" timeOnly="true" required="true" locale="pt"
									label="Horário Final" validator="#{solicitacaoManager.validarHora}" />

								<h:outputText value="Tipo de sala: " />
								<p:selectOneMenu id="tipo" value="#{professorManager.solicitacao.tipoSala}" effect="fade">
									<f:selectItem itemLabel="Selecione" itemValue="" />
									<f:selectItems value="#{salaManager.tiposSala}" var="tipo"
										itemLabel="#{tipo.label}" itemValue="#{tipo}" />
								</p:selectOneMenu>

								<h:outputText value="Acessorios: " />
								<p:selectCheckboxMenu
									value="#{professorManager.solicitacao.acessorios}"
									label="Acessorio" filter="true" filterText="Filter"
									filterMatchMode="startsWith" panelStyle="width:220px"
									converter="acessorio">
									<f:selectItems value="#{acessorioManager.mapListAcessorios}" />
								</p:selectCheckboxMenu>

								<h:outputText value="Observações: " />
								<p:inputTextarea id="obs"
									value="#{professorManager.solicitacao.observacao}" rows="6"
									cols="33" />
								<p:commandButton id="btSalvar" value="Reservar"
									action="#{professorManager.salvarSolicitacao}"
									update="formSolicitacao ,:dataTable">
								</p:commandButton>
								<p:messages id="mensagem" showDetail="false" autoUpdate="true"
									closable="true" redisplay="false" />
							</h:panelGrid>
						</p:panel>

					</h:form>
				</div>
			</p:layoutUnit>

			<p:layoutUnit position="east" size="500px">

				<p:dataTable id="dataTable" var="lista"
					value="#{professorManager.listaSolicitacao}"
					style="max-width: 500px; min-width:500px; box-shadow: 1px 5px 15px 1px #888;" paginator="true"
					rows="10"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="5,10,15"
					emptyMessage="Nenhum registro encontrado.">
					<f:facet name="header">  
				           Solicitações
				    </f:facet>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Qtd. Alunos" />
						</f:facet>
						<h:outputText value="#{lista.nrAlunos} alunos" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Data" />
						</f:facet>
						<h:outputText value="#{lista.dataInicial}">
							<f:convertDateTime pattern="dd/MM/yyyy" />
						</h:outputText>
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Status" />
						</f:facet>
						<h:outputText value="#{lista.estado}" />
					</p:column>

				</p:dataTable>
			</p:layoutUnit>
		</p:layout>

	</h:body>
</f:view>
</html>